package org.example.cicdi.service.impl.second;


import org.example.cicdi.enums.EnumWhiteColumnAnnotation;
import org.example.codegenerate.modelext.WebVo.annotation.Column.ValidateVo;
import org.example.codegenerate.modelext.WebVo.domian.column.ColumnVoDomain;

import org.example.codegenerate.modelext.WebVo.domian.table.WebModelVo;
import org.springframework.stereotype.Service;

import java.lang.reflect.Field;
import java.util.List;

@Service
public class ValidteVoAnnotatonImpleServiceSecond implements FieldAnnotationServiceSecond {

	@Override
	public String getCode() {
		return EnumWhiteColumnAnnotation.ValidateVo.getCode();
	}

	/*@Override
	public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column, TableVoDomain tableVoDomain, List<WebModelVo> webModelVoList) {
		org.jeecg.modules.codegenerate.modelext.WebVo.annotation.Column.ValidateVo validateVo=field.getAnnotation(org.jeecg.modules.codegenerate.modelext.WebVo.annotation.Column.ValidateVo.class);

		*//*if (db == null) {
			db = new org.jeecg.modules.codegenerate.modelext.WebVo.domian.column.DbVo();
			column.setDbVo(db);
		}
*//*
		if (validateVo != null) {
			ValidateVo validateDomain = new ValidateVo();
			validateDomain.setDictField(validateVo.dictField());
			validateDomain.setFieldHref(validateVo.fieldHref());
			validateDomain.setDictTable(validateVo.dictTable());

			validateDomain.setFieldValidType(validateVo.fieldValidType());
			validateDomain.setFieldMustInput(validateVo.fieldMustInput());
			validateDomain.setDictText(validateVo.dictText());

			column.setValidateVo(validateDomain);
		}

		return column;
	}*/
	//这个方法中传入了WebModelVo，及WebModelVoList没有作用
	public ColumnVoDomain handleFieldVo(Field field, ColumnVoDomain column, WebModelVo webModelVo, List<WebModelVo> webModelVoList){
		ValidateVo validateVo=field.getAnnotation(ValidateVo.class);

		/*if (db == null) {
			db = new org.jeecg.modules.codegenerate.modelext.WebVo.domian.column.DbVo();
			column.setDbVo(db);
		}
*/
		if (validateVo != null) {
			org.example.codegenerate.modelext.WebVo.domian.column.ValidateVo validateDomain = new org.example.codegenerate.modelext.WebVo.domian.column.ValidateVo();
			validateDomain.setFieldHref(validateVo.fieldHref());
			validateDomain.setFieldValidType(validateVo.fieldValidType());
			validateDomain.setFieldMustInput(validateVo.fieldMustInput());


			validateDomain.setDictField(validateVo.dictField());
			validateDomain.setDictTable(validateVo.dictTable());
			validateDomain.setDictText(validateVo.dictText());

			column.setValidateVo(validateDomain);
		}

		return column;
	}
}
